package id.net.iconpln.bb.client.view;

import id.net.iconpln.bb.client.model.BbMstPembangkitBean;
import id.net.iconpln.bb.client.model.Stock;
import id.net.iconpln.bb.client.service.PortRPCService;
import id.net.iconpln.bb.client.service.PortRPCServiceAsync;
import id.net.iconpln.bb.client.util.ClientModule;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.DateTimePropertyEditor;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.MultiField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.TimeField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.table.NumberCellRenderer;
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PageBbPortSandar extends LayoutContainer {
	private final PortRPCServiceAsync service = GWT.create(PortRPCService.class);
	private FormBinding formBindings;  
	private FormData formData; 
	private ListStore storeKplSandar,storeKplAntri, storeJetty;
	private Grid gridKplSandar, gridKplAntri;
	private ComboBox cboJetty;
	private DateField tglTa, dateF;
	private TextField<String> noAntri;
	private TimeField timeF;
	private Button bSubmit;
	
	  @Override  
	  protected void onRender(Element parent, int index) {  
	    super.onRender(parent, index);  
	    setLayout(new FitLayout());
	    initStore();
	    formData = new FormData("-20"); 
	    ContentPanel cp = new ContentPanel();  
	   
	    cp.setHeaderVisible(false);
	    cp.setFrame(true);  
	    cp.setSize(900, 400);  
	    cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); 
//	    cp.setLayout(new RowLayout(Orientation.VERTICAL));	  
	  
	    gridKplSandar = createGridSandar();  
	    gridKplSandar.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplSandar.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<BaseModel>>() {  
	          public void handleEvent(SelectionChangedEvent<BaseModel> be) {  
	            if (be.getSelection().size() > 0) {  
	              noAntri.setVisible(false);
	              bSubmit.setEnabled(false);
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbJadwal = new ToolBar();
	    tbJadwal.add(new LabelToolItem("<b>Data Kapal Sandar</b>"));
	    tbJadwal.add(new SeparatorToolItem());
	    
//	    aktivitasDermaga("pengiriman","PENGIRIMANPORTBYALLPEMASOK", "","");
//	    aktivitasDermaga("master","JETTY","", "");
	    aktivitasDermaga("antri","KEDATANGAN","", "");
	    aktivitasDermaga("antri","SANDAR","", "");
	    
	    gridKplAntri = createGridAntri();
	    gridKplAntri.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplAntri.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<BaseModel>>() {  
	    	
	          public void handleEvent(SelectionChangedEvent<BaseModel> be) {
	        	  bSubmit.setEnabled(true);
	            if (be.getSelection().size() > 0) {  
	              noAntri.setVisible(true); 		
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbPltu = new ToolBar();
	    tbPltu.add(new LabelToolItem("<b>Data Kapal Antri</b>"));
	    tbPltu.add(new SeparatorToolItem());	    	    
	    

	    FormPanel panel = createForm(); 
	    panel.setScrollMode(Scroll.AUTO);
	    formBindings = new FormBinding(panel, true);  
//	    formBindings.setStore((Store) grid.getStore());  
	    
	    
	    ContentPanel pKplSandar = new ContentPanel();
	    pKplSandar.setHeaderVisible(false);
//	    pKplSandar.setLayout(new FitLayout());
	    pKplSandar.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplSandar.add(gridKplSandar,new RowData(1, 1));
	    pKplSandar.setTopComponent(tbJadwal);

	    ContentPanel pKplAntri = new ContentPanel();
	    pKplAntri.setHeaderVisible(false);
	    pKplAntri.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplAntri.add(gridKplAntri,new RowData(1, 1));
	    pKplAntri.setTopComponent(tbPltu);

	    
	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);
	    p.setLayout(new RowLayout(Orientation.VERTICAL));	    	    
	    p.add(pKplAntri, new RowData(.99, .5));
	    p.add(pKplSandar, new RowData(.99, .5));
//	    p.setTopComponent(tbPltu);

	    
	    cp.add(panel, new RowData(.4, 1));
	    cp.add(p, new RowData(.6, 1));	    
	    
//		setScrollMode(Scroll.AUTO);		
	    add(cp, new FitData(5));  
	  }  
	  
	  private void initStore(){
		  storeKplSandar = new ListStore(); 
		  storeKplAntri = new ListStore(); 
//		  storeJetty = new ListStore();
	  }
	  private Grid createGridAntri(){
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
		    column = new ColumnConfig();  
		    column.setId("no_kedatangan");  
		    column.setHeader("No Antri");    
		    column.setWidth(150);    
		    configs.add(column);  
		    
		    column = new ColumnConfig();  
		    column.setId("kode_jetty");  
		    column.setHeader("Jetty");    
		    column.setWidth(150);    
		    configs.add(column);  
		    
		    column = new ColumnConfig();  
		    column.setId("nama_transport");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	

	    
//		    
		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Pemasok");  
		    column.setWidth(150);  
		    configs.add(column);  	  
		    
		    column = new ColumnConfig();  
		    column.setId("time");  
		    column.setHeader("ETA");
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("tgl_td");  
		    column.setHeader("ETD");
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    
		    column = new ColumnConfig();  
		    column.setId("volume");  
		    column.setHeader("Vol");    
		    column.setWidth(100);    
		    configs.add(column);

		    storeKplAntri.setMonitorChanges(true);  
		  
		    ColumnModel cm = new ColumnModel(configs);  
		  
		    gridKplAntri = new Grid(storeKplAntri, cm);  
		    gridKplAntri.getView().setEmptyText("Data Empty");  
		    gridKplAntri.setBorders(false);  
//		    grid.setAutoExpandColumn("pemasok");  
		    gridKplAntri.setLoadMask(true);  
		    gridKplAntri.mask("load Data ...","x-mask-loading");
		    gridKplAntri.setBorders(true);  
		    gridKplAntri.addListener(Events.CellClick, new Listener<BaseEvent>() {            
	            public void handleEvent(BaseEvent ge) {
	            	try{
//	            		String tgl_ta = gridKplAntri.getSelectionModel().getSelectedItem().get("time");
//	            		String tgl_td = gridKplAntri.getSelectionModel().getSelectedItem().get("tgl_td");
//	            		String norakor = gridKplAntri.getSelectionModel().getSelectedItem().get("kode_jetty").toString();
////	                	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy"); 
////	                	Date tgl = dateFormat.parse(test);
////	                	tglTd.setRawValue(tgl_td);
//	                	tglTa.setRawValue(tgl_ta);
//	                	cboJetty.setRawValue(norakor);
	              		String mulai_sandar = gridKplSandar.getSelectionModel().getSelectedItem().get("time_merapat");
	                  	timeF.setRawValue(" ");
	                  	dateF.setRawValue("");

	                	
	                	
//	                	getdataRakor_kon(norakor);
	                	
	            	}catch (Exception e) {
						// TODO: handle exception
	            		e.getMessage();
					}
	            	
	            	
	            	
	            }
			});

		  
		    return gridKplAntri;  
		  }   

	  
	  private FormPanel createForm() {  
	    FormPanel panel = new FormPanel();	    
	    panel.setHeaderVisible(false);
	    
	    FieldSet fieldSet = new FieldSet();  
	    fieldSet.setHeading("Pengajuan Sandar");  
	    fieldSet.setCollapsible(false);
	    
	  
	    FormLayout layout = new FormLayout();  
	    layout.setLabelWidth(150);  
	    fieldSet.setLayout(layout);  

	    noAntri = new TextField<String>();  
	    noAntri.setName("no_kedatangan");  
	    noAntri.setFieldLabel("No Antri");    
	    fieldSet.add(noAntri, formData);	  	  
	    
	    final TextField<String> idKedatangan = new TextField<String>();  
	    idKedatangan.setName("id_kedatangan");
	    idKedatangan.setVisible(false);
	    idKedatangan.setFieldLabel("id_kedatangan");    
	    fieldSet.add(idKedatangan, formData);
	    
	    final TextField<String> noPengiriman = new TextField<String>();  
	    noPengiriman.setName("no_pengiriman");  
	    noPengiriman.setFieldLabel("No Pengiriman");    
	    fieldSet.add(noPengiriman, formData);	  	  
	    	     
	    

	    final TextField<String> idPengiriman = new TextField<String>();  
	    idPengiriman.setName("id_pengiriman");
	    idPengiriman.setVisible(false);
	    idPengiriman.setFieldLabel("id_pengiriman");    
	    fieldSet.add(idPengiriman, formData);	  	  

	    final TextField<String> noJadwal = new TextField<String>();  
	    noJadwal.setName("no_jadwal");
	    noJadwal.setVisible(false);
	    noJadwal.setFieldLabel("no_jadwal");    
	    fieldSet.add(noJadwal, formData);	  	  

	    final TextField<String> noRakor = new TextField<String>();  
	    noRakor.setName("no_rakor");
	    noRakor.setVisible(false);
	    noRakor.setFieldLabel("no_rakor");    
	    fieldSet.add(noRakor, formData);
	    
	    TextField<String> time = new TextField<String>();	    
	    time.setName("time");  
	    time.setFieldLabel("Mulai Antri");    
	    fieldSet.add(time, formData);

//	    TextField<String> timeSandar = new TextField<String>();	    
//	    timeSandar.setName("time_sandar");  
//	    timeSandar.setFieldLabel("Selesai Antri");    
//	    fieldSet.add(timeSandar, formData);
	    
	    MultiField multi = new MultiField();
		multi.setFieldLabel("Selesai Antri");
		multi.setSpacing(10);
	
		dateF = new DateField();
		dateF.setWidth(90);
		dateF.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
  
	    timeF = new TimeField();
	    timeF.setWidth(90);
		
	    multi.add(dateF);
        multi.add(timeF);
	    
		fieldSet.add(multi, formData);
		
	    TextField<String> pemasok = new TextField<String>();	    
	    pemasok.setName("pemasok");  
	    pemasok.setFieldLabel("Pemasok");    
	    fieldSet.add(pemasok, formData);
	    
	    final TextField<String> idPemasok = new TextField<String>();  
	    idPemasok.setName("id_pemasok");
	    idPemasok.setVisible(false);
	    idPemasok.setFieldLabel("id_pemasok");    
	    fieldSet.add(idPemasok, formData);
	    	
	    TextField<String> namakpl = new TextField<String>();
	    namakpl.setName("nama_transport");  
	    namakpl.setFieldLabel("Nama Kpl / Tongkang");	    
	    fieldSet.add(namakpl, formData);
	    
	    final TextField<String> idTransportir = new TextField<String>();  
	    idTransportir.setName("id_transportir");
	    idTransportir.setVisible(false);
	    idTransportir.setFieldLabel("id_transportir");    
	    fieldSet.add(idTransportir, formData);
	    
	    
	    
	    TextField<String> jetty = new TextField<String>();
	    jetty.setName("kode_jetty");  
	    jetty.setFieldLabel("Jetty");	    
	    fieldSet.add(jetty, formData);
	    
	    final TextField<String> idUnitJetty = new TextField<String>();
	    idUnitJetty.setName("id_unit_jetty");  
	    idUnitJetty.setVisible(false);
	    idUnitJetty.setFieldLabel("id_unit_jetty");	    
	    fieldSet.add(idUnitJetty, formData);
	    
	    
	    
	    panel.add(fieldSet);  	     

	    FieldSet fieldSet2 = new FieldSet();  
//	    fieldSet3.setHeading("Pengajuan Antri");  
	    fieldSet2.setCollapsible(false);

	    FormLayout layout3 = new FormLayout();  
	    layout3.setLabelWidth(100);  
	    fieldSet2.setLayout(layout3);  

	    
	    CheckBox check1 = new CheckBox();  
	    check1.setBoxLabel("Bill Of Leading");  
	  
	    CheckBox check2 = new CheckBox();  
	    check2.setBoxLabel("Manifest");  
//	    check2.setValue(true);  
//	  
	    CheckBox check3 = new CheckBox();  
	    check3.setBoxLabel("Other");  
//	  
	    CheckBoxGroup checkGroup = new CheckBoxGroup();  
	    checkGroup.setFieldLabel("Sertifikat");  
	    checkGroup.add(check1);  
	    checkGroup.add(check2);  
//	    checkGroup.add(check3);  
	    fieldSet2.add(checkGroup, formData);
	    	    	   


//	    
	    panel.add(fieldSet2);

	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);	    
	    p.setButtonAlign(HorizontalAlignment.RIGHT);  
	    p.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
//	        grid.getStore().rejectChanges();  
	      }  
	    }));  
	    bSubmit = new Button("Submit");
	    p.addButton(bSubmit);
	    
//	    p.addButton(bSubmit, new SelectionListener<ButtonEvent>() {
	    bSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
	    	 
	    	  MessageBox.confirm("Info", "Apakah Anda Yakin Ingin Menyimpan Data?",new Listener<MessageBoxEvent>() {

					@Override
					public void handleEvent(MessageBoxEvent be) {
						// TODO Auto-generated method stub
						Button btn = be.getButtonClicked();
						if (btn.getText().equals("Yes")){

					    	   Map mapParam = new FastMap();
					    	  	mapParam.put("no_kedatangan", noAntri.getValue());
					    	  	mapParam.put("id_kedatangan", idKedatangan.getValue());
					    	  	mapParam.put("id_pengiriman", idPengiriman.getValue());
					    		mapParam.put("no_pengiriman", noPengiriman.getValue());	    		
				//	    		mapParam.put("no_jadwal", noJadwal.getValue());
					    		mapParam.put("no_rakor", noRakor.getValue());
					    		mapParam.put("id_transportir", idTransportir.getValue());
					    		mapParam.put("id_pemasok", idPemasok.getValue());
					    		mapParam.put("id_unit_jetty", idUnitJetty.getValue());
					    		mapParam.put("time_merapat", dateF.getRawValue() + " "+ timeF.getRawValue());
					    		mapParam.put("tanggal", dateF.getRawValue());
					    	    mapParam.put("id_pltu", Registry.get("idPltu").toString());
					    		mapParam.put("createby", Registry.get("whoAmI").toString());
					    		mapParam.put("app_access", "WEB");
				    			mapParam.put("crud", "CREATE");
				//
					    		
					    		Set set = mapParam.entrySet(); 
					    		// Get an iterator 
					    		Iterator i = set.iterator(); 
					    		// Display elements 
					    		while(i.hasNext()) { 
					    		Map.Entry me = (Map.Entry)i.next(); 
						    		GWT.log(me.getKey() + ": " + me.getValue()); 
					    		} 
					    		
					    		service.insertDermagaBb("BONGKAR", mapParam,new AsyncCallback<List<Map>>() {
					    			public void onFailure(Throwable caught) {
					    				GWT.log(caught.getMessage(), null);
					    			}
				
					    			public void onSuccess(List<Map> result) {	    				
					    				Info.display("debug ","notification code " + result );	    					    				
				//	    				gridKplSandar.mask("load Data ....","x-mask-loading");
//					    				gridKplSandar.unmask();
					    			    aktivitasDermaga("antri","KEDATANGAN","", "");
					    			    aktivitasDermaga("antri","SANDAR","", "");
					    			    //					    				MessageBox.alert("Informasi", " " + result, null);
					    			}
					    		});
						  }		
						}
					
					});		
	    	  }
	    });  

	    panel.add(p);
	    
	    return panel;  
	  }  

	  private Grid createGridSandar() {  
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Pemasok");  
		    column.setWidth(150);  
		    configs.add(column); 

		    
		    column = new ColumnConfig();  
		    column.setId("nama_transport");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	
		    
		    column = new ColumnConfig();  
		    column.setId("kode_jetty");  
		    column.setHeader("Jetty");  
		    column.setWidth(100);  
		    configs.add(column);  	  
		    
		    column = new ColumnConfig();  
		    column.setId("time_merapat");  
		    column.setHeader("Mulai Sandar");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy hh.mm"));
		    column.setWidth(150);  
		    configs.add(column);  

//		    column = new ColumnConfig();  
//		    column.setId("tgl_td");  
//		    column.setHeader("ETD");  
//		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
//		    column.setWidth(150);  
//		    configs.add(column);  
//
//		    
//		    column = new ColumnConfig();  
//		    column.setId("volume");  
//		    column.setHeader("Vol (Ton)");    
//		    column.setWidth(100);    
//		    configs.add(column);

		    	            		      
//		    column = new ColumnConfig();  
//		    column.setId("kualitas");  
//		    column.setHeader("Kualitas (kal)");    
//		    column.setWidth(150);  
//		    configs.add(column);		    


//		    column = new ColumnConfig();  
//		    column.setId("pic");  
//		    column.setHeader("CP");  
//		    column.setWidth(150);  
//		    configs.add(column);  

		    
//		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    storeKplSandar.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
	  
	    gridKplSandar = new Grid(storeKplSandar, cm);  
	    gridKplSandar.getView().setEmptyText("Data Empty");
	    gridKplSandar.setLoadMask(true);  
	    gridKplSandar.mask("load Data ...","x-mask-loading");
	    gridKplSandar.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    gridKplSandar.setBorders(true);  
	    gridKplSandar.addListener(Events.CellClick, new Listener<BaseEvent>() {            
          public void handleEvent(BaseEvent ge) {
          	try{

//          		String tgl_td = gridKplSandar.getSelectionModel().getSelectedItem().get("tgl_td");
//          		String norakor = gridKplAntri.getSelectionModel().getSelectedItem().get("kode_jetty").toString();
//              	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy"); 
//              	Date tgl = dateFormat.parse(test);
          		String mulai_sandar = gridKplSandar.getSelectionModel().getSelectedItem().get("time_merapat");
              	timeF.setRawValue("00.00");
              	dateF.setRawValue(mulai_sandar);
              	
          	}catch (Exception e) {
					// TODO: handle exception
          		e.getMessage();
				}

           	
          }
		});

	    return gridKplSandar;  
	  }   
	 

	  
	  private void aktivitasDermaga(String module, final String codectrl , String put1,String param1){
		  Map mapParam = new FastMap();
		  mapParam.put("id_pltu", Registry.get("idPltu").toString());
			  service.getListDermagaBy(codectrl, mapParam,new AsyncCallback<List<Map>>() {
		  			public void onFailure(Throwable caught) {
		  				GWT.log(caught.getMessage(), null);
		  			}
		  			public void onSuccess(List<Map> result) {
		  			     if (codectrl.equals("KEDATANGAN")){
		  			    	storeKplAntri.removeAll();
		  			    	storeKplAntri.add(ClientModule.setListBaseModelFromListMap(result));
		  			    	gridKplAntri.unmask();
		  			     }else if(codectrl.equals("SANDAR")){
			  			    	storeKplSandar.removeAll();
			  			    	storeKplSandar.add(ClientModule.setListBaseModelFromListMap(result));
			  			    	gridKplSandar.unmask();
		  			    	 
		  			     }
		  			   
		  			}
		  		});
	  }
}
